package com.scs.application.modules.sys.controller;

import com.alibaba.fastjson.JSON;
import com.scs.application.core.consts.Const;
import com.scs.application.core.utils.FileUtils;
import com.scs.application.modules.sys.dto.IconFontDTO;
import com.scs.application.modules.sys.model.RestResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 */
@RestController
@RequestMapping("/program/icons")
public class IconfontController {

    @GetMapping("/all")
    public RestResult findAll() {
//        String iconfonts = FileUtils.readFile(Const.ICONFONT_SRC);
        String iconfonts = FileUtils.readFileStore(Const.getIconFontSrc());

        try {
            IconFontDTO iconFontDTO = JSON.parseObject(iconfonts, IconFontDTO.class);
            return RestResult.ok("获取成功", iconFontDTO);
        } catch (Exception e) {
            return RestResult.error("获取失败");
        }
    }
}
